
/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package Apusic.impl;

import Apusic.ApusicPackage;
import Apusic.JMSQueue;
import Apusic.JMSQueueManager;

import java.util.Collection;
import java.util.Collection;
import java.util.Collection;
import java.util.Collection;
import java.util.Collection;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import javax.management.ObjectName;
import org.eclipse.emf.ecore.EObject;
import com.apusic.admin.config.*;
import com.apusic.admin.*;

import cn.edu.pku.sei.ra.wrapping.CommonWrapping.WrappingEObject;
import cn.edu.pku.sei.ra.wrapping.CommonWrapping.impl.WrappingEObjectImpl;
import cn.edu.pku.sei.ra.wrapping.CommonWrapping.util.EObjectContainmentEListForWrapping;
import cn.edu.pku.sei.ra.wrapping.CommonWrapping.util.EObjectResolvingEListForWrapping;
import cn.edu.pku.sei.ra.wrapping.CommonWrapping.util.ImagePool;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>JMS Queue Manager</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link Apusic.impl.JMSQueueManagerImpl#getJmsQueues <em>Jms Queues</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class JMSQueueManagerImpl extends WrappingEObjectImpl implements JMSQueueManager
{
  /**
   * The cached value of the '{@link #getJmsQueues() <em>Jms Queues</em>}' reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getJmsQueues()
   * @generated
   * @ordered
   */
  protected EList<JMSQueue> jmsQueues;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected JMSQueueManagerImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return ApusicPackage.Literals.JMS_QUEUE_MANAGER;
  }

  
  

  
  
  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */ 
   public boolean isForCore(Object arg0){
   	boolean result=true;
   	if(core==null) return false;
    try{
    result=true;
    }
    catch(Exception e){
      result=false;
    }
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */ 
  public List listSubCores(int featureID){
    List result=new ArrayList();
  
    JMSServiceMgr core=(JMSServiceMgr)this.getCore();
    if(core==null) 
      return result;
    switch(featureID){
    
    case ApusicPackage.JMS_QUEUE_MANAGER__JMS_QUEUES:
  
      try {
  List<ObjectName> names = core.listJMSQueue();
            for(int i=0;i<names.size();i++)
            {
            	result.add(core.fetchJMSQueue(names.get(i).getKeyProperty("name")));
            }
  } catch (Exception e) {
    e.printStackTrace();
  }
    break;
    
  }
    return result;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */ 
  public EClass getChildClassMap(Object object){
    ApusicPackage pack=ApusicPackage.eINSTANCE;	
  
    return null;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<JMSQueue> getJmsQueues()
  {

    
    if (jmsQueues == null)
    {
  
  
    
      
      jmsQueues = new EObjectResolvingEListForWrapping<JMSQueue>(
          JMSQueue.class, 
          this, 
          ApusicPackage.JMS_QUEUE_MANAGER__JMS_QUEUES,
          ApusicPackage.eINSTANCE.getJMSQueue()
        );
        
  }
  
      ((EObjectResolvingEListForWrapping<JMSQueue>)jmsQueues)
      .refreshWrap();
  
    return jmsQueues;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case ApusicPackage.JMS_QUEUE_MANAGER__JMS_QUEUES:
        return getJmsQueues();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case ApusicPackage.JMS_QUEUE_MANAGER__JMS_QUEUES:
        getJmsQueues().clear();
        getJmsQueues().addAll((Collection<? extends JMSQueue>)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case ApusicPackage.JMS_QUEUE_MANAGER__JMS_QUEUES:
        getJmsQueues().clear();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case ApusicPackage.JMS_QUEUE_MANAGER__JMS_QUEUES:
        return jmsQueues != null && !jmsQueues.isEmpty();
    }
    return super.eIsSet(featureID);
  }

} //JMSQueueManagerImpl
